package cn.jbolt.core.db.sql;

/**
 * 排序构建器
 *
 * @ClassName: OrderBy
 * @author: JFinal学院-小木 QQ：909854136
 * @date: 2021年12月15日
 */
public class OrderBy {
	private String column;
	private String type;

	private OrderBy(String column, String type) {
		this.column = column;
		this.type = type;
	}

	public static OrderBy asc(String column) {
		return new OrderBy(column, "asc");
	}

	public static OrderBy desc(String column) {
		return new OrderBy(column, "desc");
	}

	public static OrderBy create(String column, boolean desc) {
		return desc ? desc(column) : asc(column);
	}

	public String getColumn() {
		return column;
	}

	public void setColumn(String column) {
		this.column = column;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	@Override
	public String toString() {
		return column + Sql.KEY_WHITESPACE + type;
	}
}
